using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using SJVars;
using Spacejock;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
using yWriter6.My.Resources;

namespace yWriter6
{
	[DesignerGenerated]
	internal class frmProblemWords : Form
	{
		private IContainer components;

		public ToolTip ToolTip1;

		[CompilerGenerated]
		[AccessedThroughProperty("cmdDelete")]
		private Button _cmdDelete;

		[CompilerGenerated]
		[AccessedThroughProperty("cmdEdit")]
		private Button _cmdEdit;

		[CompilerGenerated]
		[AccessedThroughProperty("cmdAdd")]
		private Button _cmdAdd;

		[CompilerGenerated]
		[AccessedThroughProperty("cmdOK")]
		private Button _cmdOK;

		[CompilerGenerated]
		[AccessedThroughProperty("Label1")]
		private Label _Label1;

		[CompilerGenerated]
		[AccessedThroughProperty("ListView1")]
		private ListView _ListView1;

		[CompilerGenerated]
		[AccessedThroughProperty("ColumnHeader1")]
		private ColumnHeader _ColumnHeader1;

		[CompilerGenerated]
		[AccessedThroughProperty("ColumnHeader2")]
		private ColumnHeader _ColumnHeader2;

		public virtual Button cmdDelete
		{
			[CompilerGenerated]
			get
			{
				return _cmdDelete;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = cmdDelete_Click;
				Button cmdDelete = _cmdDelete;
				if (cmdDelete != null)
				{
					cmdDelete.Click -= value2;
				}
				_cmdDelete = value;
				cmdDelete = _cmdDelete;
				if (cmdDelete != null)
				{
					cmdDelete.Click += value2;
				}
			}
		}

		public virtual Button cmdEdit
		{
			[CompilerGenerated]
			get
			{
				return _cmdEdit;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = cmdEdit_Click;
				Button cmdEdit = _cmdEdit;
				if (cmdEdit != null)
				{
					cmdEdit.Click -= value2;
				}
				_cmdEdit = value;
				cmdEdit = _cmdEdit;
				if (cmdEdit != null)
				{
					cmdEdit.Click += value2;
				}
			}
		}

		public virtual Button cmdAdd
		{
			[CompilerGenerated]
			get
			{
				return _cmdAdd;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = cmdAdd_Click;
				Button cmdAdd = _cmdAdd;
				if (cmdAdd != null)
				{
					cmdAdd.Click -= value2;
				}
				_cmdAdd = value;
				cmdAdd = _cmdAdd;
				if (cmdAdd != null)
				{
					cmdAdd.Click += value2;
				}
			}
		}

		public virtual Button cmdOK
		{
			[CompilerGenerated]
			get
			{
				return _cmdOK;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = cmdOK_Click;
				Button cmdOK = _cmdOK;
				if (cmdOK != null)
				{
					cmdOK.Click -= value2;
				}
				_cmdOK = value;
				cmdOK = _cmdOK;
				if (cmdOK != null)
				{
					cmdOK.Click += value2;
				}
			}
		}

		[field: AccessedThroughProperty("Label1")]
		public virtual Label Label1
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[field: AccessedThroughProperty("ListView1")]
		internal virtual ListView ListView1
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[field: AccessedThroughProperty("ColumnHeader1")]
		internal virtual ColumnHeader ColumnHeader1
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[field: AccessedThroughProperty("ColumnHeader2")]
		internal virtual ColumnHeader ColumnHeader2
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[DebuggerNonUserCode]
		public frmProblemWords()
		{
			base.FormClosing += frmProblemWords_FormClosing;
			base.Load += frmProblemWords_Load;
			InitializeComponent();
		}

		[DebuggerNonUserCode]
		protected override void Dispose(bool Disposing)
		{
			if (Disposing && components != null)
			{
				components.Dispose();
			}
			base.Dispose(Disposing);
		}

		[System.Diagnostics.DebuggerStepThrough]
		private void InitializeComponent()
		{
			components = new System.ComponentModel.Container();
			ToolTip1 = new System.Windows.Forms.ToolTip(components);
			cmdDelete = new System.Windows.Forms.Button();
			cmdEdit = new System.Windows.Forms.Button();
			cmdAdd = new System.Windows.Forms.Button();
			cmdOK = new System.Windows.Forms.Button();
			Label1 = new System.Windows.Forms.Label();
			ListView1 = new System.Windows.Forms.ListView();
			ColumnHeader1 = new System.Windows.Forms.ColumnHeader();
			ColumnHeader2 = new System.Windows.Forms.ColumnHeader();
			SuspendLayout();
			cmdDelete.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right);
			cmdDelete.AutoSize = true;
			cmdDelete.BackColor = System.Drawing.SystemColors.Control;
			cmdDelete.Cursor = System.Windows.Forms.Cursors.Default;
			cmdDelete.Font = new System.Drawing.Font("Arial", 8f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
			cmdDelete.ForeColor = System.Drawing.SystemColors.ControlText;
			cmdDelete.Location = new System.Drawing.Point(324, 155);
			cmdDelete.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			cmdDelete.Name = "cmdDelete";
			cmdDelete.RightToLeft = System.Windows.Forms.RightToLeft.No;
			cmdDelete.Size = new System.Drawing.Size(82, 41);
			cmdDelete.TabIndex = 5;
			cmdDelete.Text = "Delete";
			cmdDelete.UseVisualStyleBackColor = true;
			cmdEdit.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right);
			cmdEdit.AutoSize = true;
			cmdEdit.BackColor = System.Drawing.SystemColors.Control;
			cmdEdit.Cursor = System.Windows.Forms.Cursors.Default;
			cmdEdit.Font = new System.Drawing.Font("Arial", 8f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
			cmdEdit.ForeColor = System.Drawing.SystemColors.ControlText;
			cmdEdit.Location = new System.Drawing.Point(324, 94);
			cmdEdit.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			cmdEdit.Name = "cmdEdit";
			cmdEdit.RightToLeft = System.Windows.Forms.RightToLeft.No;
			cmdEdit.Size = new System.Drawing.Size(82, 41);
			cmdEdit.TabIndex = 4;
			cmdEdit.Text = "Edit";
			cmdEdit.UseVisualStyleBackColor = true;
			cmdAdd.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right);
			cmdAdd.AutoSize = true;
			cmdAdd.BackColor = System.Drawing.SystemColors.Control;
			cmdAdd.Cursor = System.Windows.Forms.Cursors.Default;
			cmdAdd.Font = new System.Drawing.Font("Arial", 8f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
			cmdAdd.ForeColor = System.Drawing.SystemColors.ControlText;
			cmdAdd.Location = new System.Drawing.Point(324, 28);
			cmdAdd.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			cmdAdd.Name = "cmdAdd";
			cmdAdd.RightToLeft = System.Windows.Forms.RightToLeft.No;
			cmdAdd.Size = new System.Drawing.Size(82, 41);
			cmdAdd.TabIndex = 3;
			cmdAdd.Text = "Add";
			cmdAdd.UseVisualStyleBackColor = true;
			cmdOK.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			cmdOK.AutoSize = true;
			cmdOK.BackColor = System.Drawing.SystemColors.Control;
			cmdOK.Cursor = System.Windows.Forms.Cursors.Default;
			cmdOK.Font = new System.Drawing.Font("Arial", 8f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
			cmdOK.ForeColor = System.Drawing.SystemColors.ControlText;
			cmdOK.Location = new System.Drawing.Point(324, 423);
			cmdOK.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			cmdOK.Name = "cmdOK";
			cmdOK.RightToLeft = System.Windows.Forms.RightToLeft.No;
			cmdOK.Size = new System.Drawing.Size(82, 38);
			cmdOK.TabIndex = 1;
			cmdOK.Text = "OK";
			cmdOK.UseVisualStyleBackColor = true;
			Label1.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right);
			Label1.BackColor = System.Drawing.SystemColors.Control;
			Label1.Cursor = System.Windows.Forms.Cursors.Default;
			Label1.Font = new System.Drawing.Font("Segoe UI", 10f);
			Label1.ForeColor = System.Drawing.SystemColors.ControlText;
			Label1.Location = new System.Drawing.Point(14, 300);
			Label1.Name = "Label1";
			Label1.RightToLeft = System.Windows.Forms.RightToLeft.No;
			Label1.Size = new System.Drawing.Size(392, 89);
			Label1.TabIndex = 6;
			Label1.Text = "Hint: Words are case sensitive and spacing is preserved. E.g. 'end' will find 'sending' and 'send' but 'ly ' will only find 'happily we' and not 'happily.'";
			ListView1.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right);
			ListView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[2]
			{
				ColumnHeader1,
				ColumnHeader2
			});
			ListView1.Location = new System.Drawing.Point(17, 17);
			ListView1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			ListView1.Name = "ListView1";
			ListView1.Size = new System.Drawing.Size(287, 268);
			ListView1.TabIndex = 7;
			ListView1.UseCompatibleStateImageBehavior = false;
			ListView1.View = System.Windows.Forms.View.Details;
			ColumnHeader1.Text = "Problem Word";
			ColumnHeader1.Width = 110;
			ColumnHeader2.Text = "Replacement";
			ColumnHeader2.Width = 112;
			base.AutoScaleDimensions = new System.Drawing.SizeF(7f, 17f);
			base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			BackColor = System.Drawing.SystemColors.Control;
			base.ClientSize = new System.Drawing.Size(420, 475);
			base.Controls.Add(ListView1);
			base.Controls.Add(cmdDelete);
			base.Controls.Add(cmdEdit);
			base.Controls.Add(cmdAdd);
			base.Controls.Add(cmdOK);
			base.Controls.Add(Label1);
			Cursor = System.Windows.Forms.Cursors.Default;
			Font = new System.Drawing.Font("Segoe UI", 10f);
			base.Location = new System.Drawing.Point(4, 23);
			base.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			MinimumSize = new System.Drawing.Size(427, 507);
			base.Name = "frmProblemWords";
			RightToLeft = System.Windows.Forms.RightToLeft.No;
			base.ShowInTaskbar = false;
			base.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			Text = "User-Defined Problem Words";
			ResumeLayout(false);
			PerformLayout();
		}

		private void cmdAdd_Click(object eventSender, EventArgs eventArgs)
		{
			try
			{
				if (ListView1.Items.Count >= 30)
				{
					clsShared.cLang.TransMsgBox("Only @1@ words allowed.", MsgBoxStyle.Exclamation, "", Conversions.ToString(30));
				}
				else
				{
					frmProblemWord frmProblemWord = new frmProblemWord();
					if (frmProblemWord.ShowDialog() == DialogResult.OK && Operators.CompareString(frmProblemWord.txtProblemWord.Text, "", TextCompare: false) != 0)
					{
						ListView1.Items.Add(frmProblemWord.txtProblemWord.Text).SubItems.Add(frmProblemWord.txtReplacement.Text);
						SaveWords();
					}
				}
			}
			catch (Exception ex)
			{
				ProjectData.SetProjectError(ex);
				Exception ex2 = ex;
				clsShared.cLog.AddAction(ex2, MethodBase.GetCurrentMethod());
				ProjectData.ClearProjectError();
			}
		}

		private void cmdDelete_Click(object eventSender, EventArgs eventArgs)
		{
			if (ListView1.FocusedItem != null)
			{
				try
				{
					ListView1.FocusedItem.Remove();
				}
				catch (Exception ex)
				{
					ProjectData.SetProjectError(ex);
					Exception ex2 = ex;
					clsShared.cLog.AddAction(ex2, MethodBase.GetCurrentMethod());
					ProjectData.ClearProjectError();
				}
			}
		}

		private void cmdEdit_Click(object eventSender, EventArgs eventArgs)
		{
			if (ListView1.FocusedItem != null)
			{
				frmProblemWord frmProblemWord = new frmProblemWord();
				try
				{
					string text = ListView1.FocusedItem.Text;
					string text2 = ListView1.FocusedItem.SubItems[1].Text;
					frmProblemWord.DataToForm(text, text2);
					if (frmProblemWord.ShowDialog() == DialogResult.OK)
					{
						text = frmProblemWord.txtProblemWord.Text;
						text2 = frmProblemWord.txtReplacement.Text;
						if (Operators.CompareString(text, "", TextCompare: false) != 0)
						{
							ListView1.FocusedItem.Text = text;
						}
						ListView1.FocusedItem.SubItems[1].Text = text2;
						SaveWords();
					}
				}
				catch (Exception ex)
				{
					ProjectData.SetProjectError(ex);
					Exception ex2 = ex;
					clsShared.cLog.AddAction(ex2, MethodBase.GetCurrentMethod());
					ProjectData.ClearProjectError();
				}
			}
		}

		private void cmdOK_Click(object eventSender, EventArgs eventArgs)
		{
			SaveWords();
			Hide();
			cDelay.DoEvents();
		}

		private void frmProblemWords_FormClosing(object sender, FormClosingEventArgs e)
		{
			clsShared.cSettings.StoreWindowSettings("ProblemWords", this);
			clsSettings cSettings = clsShared.cSettings;
			ListView List = ListView1;
			cSettings.StoreColumnSettings("ProblemWords", ref List);
			ListView1 = List;
		}

		private void frmProblemWords_Load(object eventSender, EventArgs eventArgs)
		{
			base.Icon = Resources.yWriter5_Ico;
			clsSettings cSettings = clsShared.cSettings;
			Form Form = this;
			cSettings.ReadWindowSettings("ProblemWords", ref Form);
			clsSettings cSettings2 = clsShared.cSettings;
			ListView List = ListView1;
			cSettings2.ReadColumnSettings("ProblemWords", ref List);
			ListView1 = List;
			FillList();
			if (Operators.CompareString(clsShared.cLang.CurrentLanguage, "English", TextCompare: false) != 0)
			{
				clsShared.cLang.TranslateForm(this);
			}
			clsShared.cFormFont.SetFormFont(this, clsShared.cSettings.sGet("FormFont", modVariables.DefaultUIFont.Name), clsShared.cSettings.sGet("UIFontSize", modVariables.DefaultUIFont.Size));
		}

		private void FillList()
		{
			ListView1.Items.Clear();
			try
			{
				int num = 1;
				do
				{
					string text = clsShared.cSettings.sGet("BadWord" + Conversions.ToString(num), "");
					if (Operators.CompareString(text, "", TextCompare: false) != 0)
					{
						ListView1.Items.Add(text).SubItems.Add(clsShared.cSettings.sGet("BadWordReplacement" + Conversions.ToString(num), ""));
					}
					num++;
				}
				while (num <= 30);
			}
			catch (Exception ex)
			{
				ProjectData.SetProjectError(ex);
				Exception ex2 = ex;
				clsShared.cLog.AddAction(ex2, MethodBase.GetCurrentMethod());
				ProjectData.ClearProjectError();
			}
		}

		private void SaveWords()
		{
			try
			{
				int num = 1;
				do
				{
					if (num <= ListView1.Items.Count)
					{
						clsShared.cSettings.sSet("BadWord" + Conversions.ToString(num), ListView1.Items[num - 1].Text);
						clsShared.cSettings.sSet("BadWordReplacement" + Conversions.ToString(num), ListView1.Items[num - 1].SubItems[1].Text);
					}
					else
					{
						clsShared.cSettings.sSet("BadWord" + Conversions.ToString(num), "");
						clsShared.cSettings.sSet("BadWordReplacement" + Conversions.ToString(num), "");
					}
					num++;
				}
				while (num <= 30);
			}
			catch (Exception ex)
			{
				ProjectData.SetProjectError(ex);
				Exception ex2 = ex;
				clsShared.cLog.AddAction(ex2, MethodBase.GetCurrentMethod());
				ProjectData.ClearProjectError();
			}
		}
	}
}
